package com.youlu.campus.service.commission;

import com.youlu.campus.entity.ActivityInfo;
import com.youlu.campus.entity.commission.SharingCommissionInfo;
import com.youlu.campus.service.activity.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * 视频课程订单分佣
 */
@Service
public class CourseOrderCommissionServiceService extends AbstractCommissionService {

    @Lazy
    @Autowired
    private ActivityService activityService;

    @Override
    public Double getCurrentSharingCommissionRatio(String activityId,Integer businessType) {
        ActivityInfo activityInfo = activityService.findOne(activityId);
        if(Objects.isNull(activityInfo)){
            return ZERO;
        }
        SharingCommissionInfo sharingCommissionInfo = activityInfo.getSharingCommissionInfo();
        if(Objects.isNull(sharingCommissionInfo)||!sharingCommissionInfo.getSharingProfit()){
            return ZERO;
        }
        return sharingCommissionInfo.getVideoOrderSharingProfitRatio();
    }




}
